import { debounce } from 'common/utils.js'
export const itemListenerMixin = {
  mounted() {
    const refresh = debounce(this.$refs.scroll.refresh,200)
    this.itemImgListener = ()=>{ refresh() }
    this.$bus.$on('itemImageLoad',this.itemImgListener)
    // console.log('mixin');
  }
}

// 回到顶部mixin
import BackTop from 'components/content/backTop/BackTop.vue'
import { BACK_POSITION } from './const'
export const backTopMixin = {
  components: {
    BackTop
  },
  data() {
    return {
      isShowBackTop: false
    }
  },
  methods: {
    // 回到顶部按钮点击
    backTop(){
      this.$refs.scroll.scrollTo(0,0,300);
    },
    // methods中的大方法可以抽，但是函数中的操作一般不抽
    // 非要抽离的话就写一个函数
    listenShowBackTop(position){
      this.isShowBackTop = -position.y > BACK_POSITION
    }
  }
}